#ifndef __SQLIST_LIST_H_
#define __SQLIST_LIST_H_

#include "stdio.h"
#include <stddef.h>


#define List_Enter(ptr, type, member) ({	\
	const typeof(((type *)0)->member)*__mptr=(ptr); \
	(type *)((char *)__mptr-offsetof(type,member));	})





typedef struct List
{
	struct List * next; 
	struct List * prev;

}List_Head;

static inline void List_Init(List_Head *ptr)
{
ptr->next=ptr;ptr->prev=ptr;
}


static inline void __List_Add(List_Head *New,List_Head *prev,List_Head *next)
{
	next->prev=New;
	New->prev=prev;
	New->next=next;
	prev->next=New;

}


static inline void List_Add_Tail(List_Head *New,List_Head *Head)
{
	__List_Add(New,Head->prev,Head);
}
static inline void __List_Del(List_Head *prev,List_Head *next)
{
	next->prev=prev;
	prev->next=next;
}

static inline void List_Del(List_Head *Enter)
{
	__List_Del(Enter->prev,Enter->next);	
}
static inline int List_Is_Emtpy(List_Head *Enter)
{
	return Enter->next==Enter;
}


#define List_For_Each(Pos,Head)	\
	for(Pos=(Head)->next;Pos!=(Head);Pos=Pos->next)


#define List_For_Each_Safe(Pos,Next,Head)	\
	for(Pos=(Head)->next,Next=Pos->next;Pos!=(Head);Pos=Next,Next=Pos->next)




#endif
